package kits

import (
	"io"
	"io/ioutil"
	"net/http"
	"time"
)

type httpTool struct{}

var Http httpTool

var client = http.Client{Timeout: time.Second * 60}

// Get 执行Get请求
func (*httpTool) Get(url string) (bool, string) {
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return false, "Network Create Error"
	}
	resp, err := client.Do(req)
	if err != nil {
		return false, "Network Request Error"
	}
	defer func(Body io.ReadCloser) {
		_ = Body.Close()
	}(resp.Body)
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return false, "Network Response Error"
	}
	return true, string(body)
}
